package com.mop.controller;

import com.mop.pojo.Item;
import com.mop.pojo.User;
import com.mop.service.UserService;
import com.mop.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
@CrossOrigin    //前后端进行跨域操作
public class UserController {
    @Autowired
    private UserService userService;
@GetMapping("/findAll")
public List<User> findAll(){
return  userService.findAll();

}
@PostMapping("/login")
public SysResult login(@RequestBody User user){
    String token = userService.login(user);

    if (token == null) {
        return SysResult.fail();
    }

    return SysResult.success(token);

}


}
